// import Vue from 'vue'
// import Vuex from 'vuex'
// import {
//   getItem,
//   setItem,
//   removeItem,
//   setCookie,
//   removeCookie,
//   getCookie
// } from '../utils/storage'

// Vue.use(Vuex)
// const TOKNE_KEY = 'WANGYIYIYUN_USER'
// const TOKEN_NAME = 'WANGYIYUN_TOKEN'
// export default new Vuex.Store({
//   state: {
//     mobile: '',
//     userInfo: getItem(TOKNE_KEY),
//     token: getCookie(TOKEN_NAME)
//   },
//   mutations: {
//     mobileNext (state, mobile) {
//       state.mobile = mobile
//     },
//     getuserInfo (state, userInfo) {
//       state.userInfo = userInfo
//       setItem(TOKNE_KEY, userInfo)
//     },
//     getToken (token) {
//       setCookie(TOKEN_NAME, token, 1)
//     },
//     logout () {
//       removeItem(TOKNE_KEY)
//       removeCookie(TOKEN_NAME)
//     }
//   },
//   actions: {},
//   getters: {
//     phone (state) {
//       return state.mobile
//     },
//     uid (state) {
//       return state.userInfo.userId
//     },
//     userInfo (state) {
//       return state.userInfo
//     }
//   },
//   modules: {}
// })
import Vue from 'vue'
import Vuex from 'vuex'
import { getItem, setItem, removeItem } from '../utils/storage'
Vue.use(Vuex)
const USERINFO = 'WANGYIYUN_USER'
const COOKIE = 'WYANGYIYUN_COOKIE'
export default new Vuex.Store({
  state: {
    mobile: '',
    userInfo: getItem(USERINFO),
    cookie: getItem(COOKIE)
  },
  mutations: {
    mobileNext (state, mobile) {
      state.mobile = mobile
    },
    getuserInfo (state, userInfo) {
      state.userInfo = userInfo
      setItem(USERINFO, userInfo)
    },
    getcookie (state, cookie) {
      setItem(COOKIE, cookie)
    },
    logout (state) {
      removeItem(USERINFO)
      removeItem(COOKIE)
    },
    outuser (state, userInfo) {
      state.userInfo = userInfo
    }
  },
  getters: {
    phone (state) {
      return state.mobile
    },
    userInfo (state) {
      return state.userInfo
    },
    cookie (state) {
      return state.cookie
    }
  }
})
